<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
// Test to make sure WebKit does not remove content when unbolding nested b\'s.
// See https://bugs.webkit.org/show_bug.cgi?id=30083 for detail.

function editable(sample) {
  return `<div contenteditable>${sample}</div>`;
}

function testIt(command_name, input, expected, description) {
  selection_test(editable(input), command_name, editable(expected),
                 description);
}

testIt('bold',
       '<span>^<b>1<b>2</b></b>|</span>',
       '<span>^12|</span>',
       'bold-1');
testIt('bold',
       '<span>^<b id="foo">1<b>2</b></b>|</span>',
       '<span><span id="foo">^12|</span></span>',
       'bold-2');
testIt('bold',
       '<span>^<b id="foo"><b>1</b>2</b>|</span>',
       '<span><span id="foo">^12|</span></span>',
       'bold-3');
testIt('bold',
       '<span>^<b><b><b>12</b></b></b>|</span>',
       '<span>^12|</span>',
       'bold-4');
testIt('bold',
       '<span>^<b><b><b>1</b></b>2</b>|</span>',
       '<span>^12|</span>',
       'bold-5');
testIt('italic',
       '<span>^<i>1<i>2</i></i>|</span>',
       '<span>^12|</span>',
       'italic-1');
testIt('strikeThrough',
       '<span>^<s>1<s>2</s></s>|</span>',
       '<span>^12|</span>',
       'strike-through-1');
</script>
